
import { Injectable } from '@angular/core';
import { Router, Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';


import { AssetService } from './AssetService';
import { AssetType } from '../models/AssetType';

@Injectable()
export class AssetTypeResolveService implements Resolve<AssetType[]> {

    constructor(private assetService: AssetService) {}

    resolve(route: ActivatedRouteSnapshot): Observable<AssetType[]>  {

        return this.assetService.getAssetTypes().pipe(map((res) => {
          return res.res;
        }));
    }
}

